package com.yehuishou.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yehuishou.dao.AssessmentValueDao;
import com.yehuishou.dao.BackAssessmentDao;
import com.yehuishou.dao.BackItemDao;
import com.yehuishou.pojo.AssessmentValue;
import com.yehuishou.pojo.BackAssessment;
import com.yehuishou.pojo.BackItem;
import com.yehuishou.service.AssessmentValueService;

/**
	 * 
	 * @author xiaosa
	 * @className AssessmentValueServiceImpl.java
	 * @descripe 
	 * @data 2018年6月6日
	 */
    @Service
	public class AssessmentValueServiceImpl implements AssessmentValueService{
		
		@Resource
		private AssessmentValueDao assessmentValueDao;
		
		
		@Resource
		private BackItemDao backItemDao;
		
		
		@Resource
		BackAssessmentDao backAssessmentDao;
		
		
		public void insertAssessmentValue(AssessmentValue value) {
			
			assessmentValueDao.insertAssessValue(value);
			
		}


		@Override
		public List<List<AssessmentValue>> getAssessmentValue(Integer id) {
		
			List<List<AssessmentValue>> valuelist =new ArrayList<>();
		
			BackItem back = backItemDao.getOneById(id);
		//获取商品对应的属性值集合
	List<BackAssessment> assessments=backAssessmentDao.getBackAssessment(back.getCid());
		
	AssessmentValue value = new AssessmentValue();
	value.setBack_id(id);
	
	for(int i=0;i<assessments.size();i++) {
		value.setAssess_id(assessments.get(i).getAssess_id());
	 List<AssessmentValue> assesslist=assessmentValueDao.getAssessmentValueByid(value);
	
	valuelist.add(assesslist);
	} 		
			return valuelist;
		}


		@Override
		public void deleteAssessById(Integer id) {
			assessmentValueDao.deleteAssessById(id);
		}


		@Override
		public void editAssess(AssessmentValue value) {
			assessmentValueDao.editAssess(value);
		}


		@Override
		public List<AssessmentValue> getAssessmentValue(AssessmentValue value) {
			// TODO Auto-generated method stub
			return assessmentValueDao.getAssessmentValueByid(value);
		}


		@Override
		public void deleteAssessByIds(List<Integer> ids) {
			assessmentValueDao.deleteAssessByIds(ids);
			
		}
		
		

}
